<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Paypal退款审核</title>
<body class="withvernav">
<div class="bodywrapper"> {{include file='/public/leftmenu.tpl'}}</div>
  <div class="centercontent">
    <div class="pageheader notab">
    <h1 class="pagetitle">Paypal退款</h1>
    </div>
    </div>
    <form class="stdform stdform2" method="get" id="search" action="/paypal/ajaxbutton">

      <div class="tableoptions">
      <input type="hidden" name="op" value="search">
		 <select name="platformID" id="platformID"  class="selection select2_group" style="width:100px;" onChange="getshopName()" >
        <option value="*" >平台</option>
        {{foreach from=$platform item=li key=key}}
              <option value="{{$li.id}}" {{if $platformID==$li.id}} selected{{/if}}>{{$li.name}}</option>
        {{/foreach}}
        </select>
        <select name="shopID" id="shopname"  class="selection select2_group" style="width:150px;" >
        <option value="*" >店铺</option>
        {{foreach from=$d_shop item=li key=key}}
              <option value="{{$li.id}}" {{if $shopID==$li.id}} selected{{/if}}>{{$li.name}}</option>
        {{/foreach}}
        </select>
        <select name="where" id="where" class="selection select2_group" style="width:150px;" >
          <option value="order_sn" {{if $where=='order_sn'}} selected{{/if}}>订单编号</option>
          <option value="customerid" {{if $where=='customerid'}} selected{{/if}}>用户id</option>
          <option value="tradeid" {{if $where=='tradeid'}} selected{{/if}}>交易号</option>
        </select>
       <input type="text" name="kw" id="kw" class="width200" value="{{$kw}}" placeholder="关键词" />
&nbsp;
        <select name="order" id="order" class="selection select2_group" style="width:150px;" >
          <option value="0" {{if $order=='0'}} selected{{/if}}>查看全部</option>
          <option value="1" {{if $order=='1'}} selected{{/if}}>待处理</option>
          <option value="2" {{if $order=='2'}} selected{{/if}}>审批通过</option>
          <option value="3" {{if $order=='3'}} selected{{/if}}>成功退款</option>
          <option value="4" {{if $order=='4'}} selected{{/if}}>退款异常</option>
          <option value="5" {{if $order=='5'}} selected{{/if}}>paypal直接获取</option>
        </select>
        <select name="orderd" id="orderd" class="selection select2_group" style="width:150px;" >
          <option value="asc" {{if $orderd=='asc'}} selected{{/if}}>正序</option>
          <option value="desc" {{if $orderd=='desc'}} selected{{/if}}>倒序</option>
        </select>
        <select name="timetype" id="timetype" class="selection select2_group" style="width:150px;" >
          <option value="ordertime" {{if $timetype=='ordertime'}} selected{{/if}}>订单时间</option>
          <option value="refund_time" {{if $timetype=='refund_time'}} selected{{/if}}>申请退款时间</option>
        </select>
        <input type="text"  name="starttime" value="{{$starttime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" /> - <input type="text"  name="endtime" value="{{$endtime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
        <input type="hidden"  name="status" value="{{$status}}">
        <button class="btn btn-primary" id="searchbtn">Search</button>

        <a href="/paypal/ajaxbutton?op=returnpay" target="_blank">查看需要审批的退款</a>
      </div>
      
    
    </form>
    
    <div style="clear: both"></div>
    <div class="page">
    总计退款订单金额{{$allordermon}}人民币,总计退款金额{{$refunmon}}人民币。
    <a href="/paypal/ajaxbutton?op=search&page=1&order={{$order}}&orderd={{$orderd}}&where={{$where}}&platformID={{$platformID}}&shopID={{$shopID}}&kw={{$kw}}&timetype={{$timetype}}&starttime={{$starttime}}&endtime={{$endtime}}">首页</a>
    {{if $lastpage > $zero}}  
    <a href="/paypal/ajaxbutton?op=search&page={{$lastpage}}&order={{$order}}&orderd={{$orderd}}&where={{$where}}&platformID={{$platformID}}&shopID={{$shopID}}&kw={{$kw}}&timetype={{$timetype}}&starttime={{$starttime}}&endtime={{$endtime}}">上一页</a>
    {{/if}}
   {{foreach from=$pg item=li key=key}}
    <a href="/paypal/ajaxbutton?op=search&page={{$li}}&order={{$order}}&orderd={{$orderd}}&where={{$where}}&platformID={{$platformID}}&shopID={{$shopID}}&kw={{$kw}}&timetype={{$timetype}}&starttime={{$starttime}}&endtime={{$endtime}}">{{$li}}</a>
   {{/foreach}}
   {{if $nextpage <= $pages}}  
    <a href="/paypal/ajaxbutton?op=search&page={{$nextpage}}&order={{$order}}&orderd={{$orderd}}&where={{$where}}&platformID={{$platformID}}&shopID={{$shopID}}&kw={{$kw}}&timetype={{$timetype}}&starttime={{$starttime}}&endtime={{$endtime}}">下一页</a>
   {{/if}}
    <a href="/paypal/ajaxbutton?op=search&page={{$pages}}&order={{$order}}&orderd={{$orderd}}&where={{$where}}&platformID={{$platformID}}&shopID={{$shopID}}&kw={{$kw}}&timetype={{$timetype}}&starttime={{$starttime}}&endtime={{$endtime}}">末页</a>
     共计{{$sum}}条记录，共{{$pages}}页
    </div>
  
   <!--搜索栏结束-->
<table cellpadding="0" cellspacing="0" border="0" class="stdtable" style="table-layout: fixed;">
<thead>
  <tr class="lbbt">
    <td width="3%"  bgcolor="#FEFFF1"><a onClick="allSelect('ppid[]')">全选</a></td>
    <td width="8%" bgcolor="#FEFFF1">订单编号</td>
    <td width="8%" bgcolor="#FEFFF1">用户id</td>
    <td width="8%" bgcolor="#FEFFF1">交易号</td>
    <td width="8%"  bgcolor="#FEFFF1">店铺/退款申请人</td>
    <td width="8%" bgcolor="#FEFFF1">原金额/订单金额/总价</td>
    <td  width="8%" bgcolor="#FEFFF1">货运方式/货运单号</td>
    <td width="5%" bgcolor="#FEFFF1">退款金额</td>
    <td width="8%" bgcolor="#FEFFF1">退款原因</td>
     
    <td width="8%" bgcolor="#FEFFF1">退款失败原因</td>
    
    <td width="8%" bgcolor="#FEFFF1" >订单日期/申请时间</td>
    <td width="8%" bgcolor="#FEFFF1" >退款状态</td>
    <td width="8%">选择</td>
    
  </tr>
</thead>
<tbody >

{{foreach from=$selectarr item=li key=key}}
  <tr  style="cursor:pointer">
    <td >
        <input name="ppid[]" type="checkbox" class="none" id="ppid[]" value="{{$li.order_sn}}" />
    </td>
    <td><a href='../orderlist/editorder?order_id={{$li.order_id}}' target="_blank">{{$li.order_sn}}</a></td>
    <td>{{$li.customerid}}</td>

    <td>{{$li.tradeid}}</td>


    <td style="position:relative;">
   
      <div style="margin-left:2px;">{{$li.shopname}} ({{$li.shopoper}})

    </div>
     
      <div class="lbcp">
      </div>
   </td>
    <td valign="middle">{{$li.moneytype}} {{$li.goods_originask}}<br>RMB {{$li.goods_amount}}</td>
   
    <td class="cz">
        <br>{{$li.shipping_name}}<br>{{$li.shipping_number}}
    </td>
    <td>{{$li.refund_money}}</td>
    <td>{{$li.refund_reason}}<br/>{{if $li.platfromname != 'eBay' && $li.platfromname != 'magento'}}{{$li.otherpaypal}}{{/if}}</td>
     <td>{{$li.paypal_fail}}</td>
    <td class="cz">{{$li.ordertime}}<br>{{$li.refund_time}}</td>
    {{if $li.refund_status==1}}
    <td class="cz">申请退款</td>
    {{/if}}
    {{if $li.refund_status==2}}
    <td class="cz" style="color: green">正在退款</td>
    {{/if}}
    {{if $li.refund_status==3}}
    <td class="cz" style="color: blue">退款成功</td>
    {{/if}}
    {{if $li.refund_status==4}}
    <td class="cz" style="color: red">退款失败</td>
    {{/if}}
    <td>
    {{if $li.refund_status==1}}
     {{if $managers || in_array('224',$showpower) || in_array('254',$showpower) || in_array('255',$showpower)}}
      <span onClick="agree('{{$li.order_sn}}','{{$li.pay_id}}')">批准</span>&nbsp<span onClick='cancel("{{$li.pay_id}}")'>驳回</span>
     {{/if}}
     <a href="javascript:void(0)" onClick="magentoauth('{{$li.pay_id}}')"><span>详情</span></a>
     {{/if}}    
      {{if $li.refund_status==2}}
      <a href="javascript:void(0)" onClick="magentoauth('{{$li.pay_id}}')"><span>详情</span></a>
      {{if $classid == 11 || $classid == 7}}
      <a href="javascript:void(0)" onClick="otherauth('{{$li.pay_id}}','{{$li.order_sn}}')"><span>回执</span></a>
      {{/if}}
      {{/if}}
     {{if $li.refund_status==3}}
      <a href="javascript:void(0)" onClick="magentoauth('{{$li.pay_id}}')"><span>详情</span></a>
      {{/if}}
      {{if $li.refund_status==4}}
      <a href="javascript:void(0)" onClick="magentoauth('{{$li.pay_id}}')"><span>详情</span></a>
      {{/if}}
    </td>
  </tr>
{{/foreach}}
</tbody>

</table>









     </div>
 </div>



<!-- 弹窗 -->
<!-- 
<div id="popdiv" style="z-index: 999; position: fixed; top: 50%; left: 50%; display: none; background: white;" >
			<h4>退款订单详细信息</h4>
			<table>
				<tr><td>订单编号:</td><td><span id="order_sn"></span></td></tr>
				<tr><td>订单时间/申请退款时间:</td><td><span id="ordertime"></span><span id="refund_time"></span></td></tr>
				<tr><td>平台/店铺负责人:</td><td><span id="platfromname"></span><span id="shopoper"></span></td></tr>
				<tr><td>订单金额:</td><td><span id="moneytype"></span><span id="goods_originask"></span></td></tr>
				<tr><td>退款金额:</td><td><span id="moneytype1"></span><span id="refund_money"></span></td></tr>
				<tr><td>退款理由:</td><td><span id="refund_reason"></span></td></tr>
				<tr><td><button onclick="agreetwo()" >确认退款</button></td><td><button onclick="canceltwo()">取消退款</button></td><td><button onclick="displayno()">关闭</button></td></tr>
			</table>
		</div>

 -->
<!-- magento 授权 -->
<form  method="post" id="modal_submit" action="">
        <input type="hidden" name="editid" id="editid">
        <div class="modal fade" id="magentoauth" tabindex="-1" role="dialog" aria-labelledby="magentoauth" aria-hidden="true">
            <div class="modal-dialog" style="width:740px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">× </button>
                        <h4 class="modal-title" id="sebayauth">paypa退款详情</h4>
                    </div>
                    <div class="modal-body">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr style="display: none;">
                                <td align="right" width="30%">退款编号</td>
                                <td align="left">
                                   <span id="pay_id"></span>
                            </tr>
                            <tr>
                                <td align="right" width="30%">订单编号</td>
                                <td align="left">
                                   <span id="order_sn"></span>
                            </tr>
                                                        <tr>
                                <td align="right" width="30%">订单时间/申请退款时间</td>
                                <td align="left">
                                   <span id="ordertime"></span><br/><span id="refund_time"></span>
                                    
                            </tr>
                                                        <tr>
                                <td align="right" width="30%">平台/店铺负责人</td>
                                <td align="left">
                                    <span id="platfromname"></span><br/><span id="shopoper"></span>
                                    
                            </tr>
                                                                                    <tr>
                                <td align="right" width="30%">订单金额</td>
                                <td align="left">
                                  <span id="moneytype"></span><br/><span id="goods_originask"></span>
                            </tr>
                                                        <tr>
                                <td align="right" width="30%">退款金额</td>
                                <td align="left">
                                    <span id="moneytype1"></span><br/><span id="refund_money"></span>
                            </tr>
                                                        <tr>
                                <td align="right" width="30%">退款理由</td>
                                <td align="left">
                                  <span id="refund_reason"></span>
                            </tr>
                           {{if $status==3}}
                                  <tr>
                                <td align="right" width="30%">退款成功</td>
                                <td align="left">
                                  <span id="success">退款成功</span>
                            </tr>
                           {{/if}}
                           {{if $status==4}}
                                  <tr>
                                <td align="right" width="30%">退款失败</td>
                                <td align="left">
                                  <span id="success">退款失败</span>
                            </tr>
                           {{/if}}
      
                        </table>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default"
                                    data-dismiss="modal"> 关闭 </button>
                            <!--
                            <button type="button" class="btn btn-primary"  onclick="atmangban()">授权</button>-->
                              {{if $status==1}}
                            {{if $managers || in_array('224',$showpower)}}
                            <button type="button" class="btn btn-primary" onClick="agreetwo()">批准</button>
                            <button type="button" class="btn btn-primary" onClick="canceltwo()">驳回</button>
                            {{/if}}
                            {{/if}}

                         

                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
        </div>
        <!-- /.modal -->
    </form>


<form  method="post" id="modal_submit" action="">
        <input type="hidden" name="editid" id="editid">
        <div class="modal fade" id="otherauth" tabindex="-1" role="dialog" aria-labelledby="otherauth" aria-hidden="true">
            <div class="modal-dialog" style="width:740px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true">× </button>
                        <h4 class="modal-title" id="sebayauth">paypa退款回执（财务填写）</h4>
                    </div>
                    <div class="modal-body">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td align="right" width="30%">退款编号</td>
                                <td align="left">
                                   <span id="pay_id1"></span>
                            </tr>
                            <tr>
                                <td align="right" width="30%">订单编号</td>
                                <td align="left">
                                   <span id="order_sn1"></span>
                            </tr>
                            <tr>
                              <td align="right" width="30%">填写paypal交易号</td>
                              <td align="left">
                                <input type="text" name="payreturnid" id="payreturnid">
                              </td>
                            </tr>
          
      
                        </table>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default"
                                    data-dismiss="modal"> 关闭 </button>
                            <!--
                            <button type="button" class="btn btn-primary"  onclick="atmangban()">授权</button>-->
                              
                            
                            <button type="button" class="btn btn-primary" onClick="receipt()">提交</button>
                          

                         

                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
        </div>
        <!-- /.modal -->
    </form>










<script type="text/javascript">
          $(function(){
				$("#popdiv").css({"margin-left":-$("#popdiv").width()/2,"margin-top":-$("#popdiv").height()/2})
			})


function agree(order_sn,pay_id) {
	$.post("/paypal/ajaxbutton?op=agree",{order_sn:order_sn,pay_id:pay_id},function(data){alert("已提交退款")
document.location.href = "/paypal/ajaxbutton?op=returnpay";
});
}
function cancel(pay_id){
$.post("/paypal/ajaxbutton?op=cancel",{pay_id:pay_id},function(data){alert("已取消退款")
document.location.href = "/paypal/paypalRefundTo";
});
}
function agreetwo(){
  var order_sn=$("#order_sn").text();
  var pay_id=$("#pay_id").text();
$.post("/paypal/ajaxbutton?op=agree",{order_sn:order_sn,pay_id:pay_id},function(data){alert(data)
document.location.href = "/paypal/ajaxbutton?op=returnpay";
});
}
function canceltwo(){
	 var pay_id=$("#pay_id").text();
$.post("/paypal/ajaxbutton?op=cancel",{pay_id:pay_id},function(data){alert("已取消退款")
document.location.href = "/paypal/paypalRefundTo";
});
}

function receipt(){
  var pay_id=$("#pay_id1").text();
  var rand = Math.ceil(Math.random()*10);
  var payreturnid=$("#payreturnid").val();
$.post("/paypal/ajaxbutton?op=receipt",{pay_id:pay_id,payreturnid:payreturnid},function(data){
  alert("已提交回执")
document.location.href = "/paypal/paypalRefundTo?rand="+rand;
});
}
	function magentoauth(pay_id){
			 $.post("/paypal/ajaxbutton?op=pop",{pay_id:pay_id},
                    function(data){

                    	$('#magentoauth').modal('show');	
                    if(data.code==1){
                        $("#pay_id").html(data.pay_id);
                        $("#order_sn").html(data.order_sn);
                        $("#refund_time").html(data.refund_time);
                        $("#refund_money").html(data.refund_money);
                        $("#refund_reason").html(data.refund_reason);
                        $("#platfromname").html(data.platfromname);
                        $("#shopoper").html(data.shopoper);
                        $("#goods_originask").html(data.goods_originask);
                        $("#moneytype").html(data.moneytype);
                        $("#moneytype1").html(data.moneytype);
                        $("#ordertime").html(data.ordertime);
                    }else{
                        //alert(data.msg);return ;
                    }

                    },"json");


	}

//回执
  function otherauth(pay_id,order_sn) {
    $('#otherauth').modal('show');
    $("#order_sn1").html(order_sn);
    $("#pay_id1").html(pay_id);
  }


</script>







</body>
</html>